<template>
  <tree-list :listFn="listFn"
             :saveFn="treeSaveFn"
             :batchFn="batchFn"
             :deleteFn="deleteFn"
             @tree-select="onTreeSelect"
             :label="label"
             :title="title"
             :editable="editable"
  >

  </tree-list>
</template>
<script>
import treeList from '@/comp/customer/tree-list'
import {postListAllCategory, postSaveCategory, postBatchUpdateCategory, postDeleteCategory} from '@/api/customer/category'

export default {
  name: 'customer-category-tree',
  cnName: '客户-供应商-树',
  components: { treeList },
  props: {
    label: String,
    title: String,
    editable: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      treeSaveFn: postSaveCategory,
      batchFn: postBatchUpdateCategory,
      deleteFn: postDeleteCategory,
      categoryId: ''
    }
  },
  methods: {
    async listFn() {
      const res = await postListAllCategory({}, {orderByColumn: 'px'})
      return res.data
    },
    onTreeSelect(id, data) {
      this.categoryId = id
      this.$emit('tree-select', id, data)
    }
  },
  mounted() {
  }
}
</script>
<style scoped lang="scss">

</style>
